package com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler;

import com.iwhalecloud.bss.kite.common.constant.KeyConsts;
import com.iwhalecloud.bss.kite.cucc.service.attr.LocalAttrHelper;
import com.iwhalecloud.bss.kite.cucc.service.attr.handler.ConvergenceAttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.annotation.AttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.impl.AbstractAttrLinkageHandler;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import org.springframework.stereotype.Service;

import java.util.Objects;

@Service
@AttrHandler(ConvergenceAttrHandler.class)
public class ConvergenceAttrLinkHandler extends AbstractAttrLinkageHandler<AttrData> {
    @Override
    public void handle(KiteAttr attr, KiteInst inst, AttrData data) {
        String fieldName = attr.getFieldName();
        switch(fieldName) {
            case "200003068":
                if ("1_0000106".equals(attr.getValue())) {
                    KiteAttr attr1 = inst.getAttr("200003555");
                    if (Objects.nonNull(attr1)) {
                        LocalAttrHelper.hiddenOrDisplayProdAttr(data.getSceneInstId(), inst, attr1, KeyConsts.PROD_ATTR_SHOW_TYPE_M, attr1.getOriginValue());
                    }
                } else {
                    KiteAttr attr1 = inst.getAttr("200003555");
                    if (Objects.nonNull(attr1)) {
                        LocalAttrHelper.hiddenOrDisplayProdAttr(data.getSceneInstId(), inst, attr1, KeyConsts.PROD_ATTR_SHOW_TYPE_E, attr1.getOriginValue());
                    }
                }
                break;
            case "200003069":
                if ("1_0000106".equals(attr.getValue())) {
                    KiteAttr attr1 = inst.getAttr("200003557");
                    if (Objects.nonNull(attr1)) {
                        LocalAttrHelper.hiddenOrDisplayProdAttr(data.getSceneInstId(), inst, attr1, KeyConsts.PROD_ATTR_SHOW_TYPE_M, attr1.getOriginValue());
                    }
                } else {
                    KiteAttr attr1 = inst.getAttr("200003557");
                    if (Objects.nonNull(attr1)) {
                        LocalAttrHelper.hiddenOrDisplayProdAttr(data.getSceneInstId(), inst, attr1, KeyConsts.PROD_ATTR_SHOW_TYPE_E, attr1.getOriginValue());
                    }
                }
                break;
            default:
                break;
        }
    }

    @Override
    public void handleStyle(KiteAttr attr, KiteInst inst, AttrData data) {

    }
}
